package com.test.exam.dao;

import java.util.HashMap;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.test.exam.commons.PageHelper;
import com.test.exam.domain.Course;

@Repository
public class CourseDao {
	private final String COURSE_NS = "com.test.exam.mapper.CourseMapper";
	
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	// 전체 반 row수
	public int getCourseCount(){
		return sqlSessionTemplate.selectOne(
				COURSE_NS+".getCourseCount");
	}
	
	//페이지 코스 목록
	public List<HashMap> getCoursesByCurrentPage(PageHelper pageHelper){
		return sqlSessionTemplate.selectList(
				COURSE_NS+".getCoursesByCurrentPage",pageHelper);
	}
	
	public int addCourse(Course course){
		return sqlSessionTemplate.insert(COURSE_NS+".addCourse",course);
	}
	
	
	
}
